<center>
	<font size=7 class='titre'>Ajouter un appartement</font><br /> <br />
</center>

<?php
if (isset($_POST['nom']))
{
	$nom = secure ($_POST['nom']);
	$pays = secure ($_POST['pays']);
	$ville = secure ($_POST['ville']);
	$adresse = secure ($_POST['adresse']);
	$description = secure ($_POST['description']);
	$caracteristiques = secure ($_POST['caracteristiques']);
	$superficie = secure ($_POST['superficie']);
	$chambres = secure ($_POST['chambres']);
	$sdb = secure ($_POST['sdb']);
	$wc = secure ($_POST['wc']);
	$jardin = secure ($_POST['jardin']);
	$format = secure ($_POST['format']);
	$type = secure ($_POST['type']);
	$prix = secure ($_POST['prix']);

	connect ($link);
	$query = 'INSERT INTO `biens` (`nom` ,`pays` ,`ville` ,`adresse`, `description` ,`superficie`,`nb_chambres`,`sdb`,`wc`,`jardin`,`type`,`format`,`caracteristiques`,`prix`) VALUES (\''.$nom.'\', \''.$pays.'\', \''.$ville.'\', \''.$adresse.'\', \''.$description.'\', \''.$superficie.'\', \''.$chambres.'\', \''.$sdb.'\', \''.$wc.'\', \''.$jardin.'\', \''.$type.'\', \''.$format.'\', \''.$caracteristiques.'\', \''.$prix.'\');';
	$res = mysql_query($query) or die("Impossible de rajouter l'appartement das la bdd.");
	deconnect($link);
	header('Location: admin-gestion_appartements.html');
}
?>
<form action='' method=post>
	<table border=1 cellpadding='5px' cellspacing='10px'>
		<tr>
			<td>Nom</td>
			<td><input name=nom size=30 /></td>
		</tr>
		<tr>
			<td>Pays</td>
			<td><?php list_countries (); ?></td>
		</tr>
		<tr>
			<td>Ville</td>
			<td><?php list_cities (); ?></td>
		</tr>
		<tr>
			<td>Adresse</td>
			<td><textarea cols=40 rows=2 name=adresse></textarea></td>
		</tr>
		<tr>
			<td>Description</td>
			<td><textarea cols=40 rows=5 name=description></textarea></td>
		</tr>
		<tr>
			<td>Caracteristiques</td>
			<td><textarea cols=40 rows=5 name=caracteristiques></textarea></td>
		</tr>
		<tr>
			<td>Superficie</td>
			<td><input name=superficie type=number /> m<sup>2</sup></td>
		</tr>
		<tr>
			<td>Chambres</td>
			<td><?php liste_nombres ('chambres', 15); ?></td>
		</tr>
		<tr>
			<td>Salle de Bain</td>
			<td><?php liste_nombres ('sdb', 5); ?></td>
		</tr>
		<tr>
			<td>WC</td>
			<td><?php liste_nombres ('wc', 5); ?></td>
		</tr>
		<tr>
			<td>Jardin</td>
			<td><select name=jardin>
					<option selected=selected value=1>oui</option>
					<option value=0>non</option>
			</select>
			</td>
		</tr>
		<tr>
			<td>Type</td>
			<td><?php list_types (); ?></td>
		</tr>
		<tr>
			<td>Format</td>
			<td><?php list_formats (); ?></td>
		</tr>
		<tr>
			<td>Prix</td>
			<td><input name=prix type=text /> &euro;</td>
		</tr>
		<tr>
			<td colspan=2>
				<center>
					<input type=submit value='Ajouter cet Appartement' />
				</center>
			</td>
		</tr>
	</table>
</form>
